import http from '../../../../util/http.js';


//获取小程序配置文件
export function FindWeixinAppConfig(postData) {
    let url = `/weixin/app/config/find`;
    return new Promise((resolve, reject) => {
        http.get(url, postData).then(response => {
            resolve(response)
        })
    });
}

//新增小程序配置信息
export function AddWeixinAppConfig(postData) {
    let url = `/weixin/app/config/add`;
    return new Promise((resolve, reject) => {
        http.post(url, postData).then(response => {
            resolve(response)
        })
    });
}


//根据小程序ID修改小程序信息
export function UpdateWeixinAppConfig(id, param) {
    let url = `/weixin/app/config/update/${id}`;
    return new Promise((resolve, reject) => {
        http.put(url, param).then(response => {
            resolve(response)
        })
    });
}


//小程序关注用户列表
export function userList(pagination, param) {
    let url = `/weixin/app/user/list/${pagination.pageSize}/${pagination.current}`;
    return new Promise((resolve, reject) => {
        http.get(url, param).then(response => {
            resolve(response)
        });
    });
}


//===========================小程序推广素材API==================


export function spreadMaterialList(pagination, param) {
    let url = `/weixin/app/spread/material/list/${pagination.pageSize}/${pagination.current}`;
    return new Promise((resolve, reject) => {
        http.get(url, param).then(response => {
            resolve(response)
        });
    });
}






export function spreadMaterialAdd(data) {
    let url = `/weixin/app/spread/material/add`;
    return new Promise((resolve, reject) => {
        http.post(url, data).then(response => {
            resolve(response)
        });
    });
}

/**
 * 根据素材生成预览文件
 * */
export  function  spreadMaterialPreview(id) {
    let url = `/weixin/app/spread/material/preview/${id}`;
    return new Promise((resolve, reject) => {
        http.get(url).then(response => {resolve(response)});
    });

}








export function spreadMaterialUpdate(id, data) {
    let url = `/weixin/app/spread/material/update/${id}`;
    return new Promise((resolve, reject) => {
        http.put(url, data).then(response => {
            resolve(response)
        });
    });
}


export function spreadMaterialDelete(id) {
    let url = `/weixin/app/spread/material/delete/${id}`;
    return new Promise((resolve, reject) => {
        http.delete(url).then(response => {
            resolve(response)
        });
    });
}


